{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "82370481-f2dc-4c12-af1b-c5c9f625acad",
   "metadata": {},
   "outputs": [],
   "source": [
    "#将无标签数据打标为doubt，固定标签‘5’\n",
    "import os\n",
    "import random\n",
    "import shutil"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3abb2d77-1ec2-4c61-a485-4adc19197740",
   "metadata": {},
   "outputs": [],
   "source": [
    "main_path = \"dataset/\"\n",
    "data_label_path = \"dataset/\"\n",
    "data_label = ['tri','T','sin','for','dou']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8929e93e-4d2e-4696-b96e-37a295c0a85d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_all_files(dir, label=None):\n",
    "    files_list = []\n",
    "    for file in os.listdir(dir):\n",
    "        if label:\n",
    "            files_list.append(dir+file+' '+str(data_label.index(label)))\n",
    "        else:\n",
    "            files_list.append(dir+file)\n",
    "    return files_list\n",
    "\n",
    "data_label_files = []\n",
    "\n",
    "for label in data_label:\n",
    "    single_label_path = data_label_path + label + '/'\n",
    "    single_label_files = get_all_files(single_label_path, label)\n",
    "    data_label_files += single_label_files\n",
    "\n",
    "random.shuffle(data_label_files)\n",
    "    \n",
    "with open(main_path+'label.txt' , 'w') as f:\n",
    "    for line in data_label_files:\n",
    "        f.write(line+'\\n')\n",
    "    f.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
